<template>
    <div>

    </div>
</template>

<script>
export default {
  name: 'login',

  data () {
    return {

    }
  },

  mounted () {
    console.log('login', 1111)
    this.$nextTick(() => {
      const timestamp = Date.parse(new Date())
      this.dd.ready(() => {
        this.dd.runtime.permission.requestAuthCode({
          corpId: process.env.CORP_ID,
          onSuccess: (info) => {
            this.$http({
              method: 'post',
              url: this.api.login,
              data: { code: info.code },
              // header: { Accept: 'application/business.report.v1+json' }
            }).then(res => {
              // console.log(res,'reslogin')
              window.localStorage.clear()
              res.data.data.expirations = timestamp + 2592000
              window.localStorage.setItem('userinfo', JSON.stringify(res.data.data.info))
              window.sessionStorage.setItem('token', res.data.data.access_token)
                // console.log( res.data.data.access_token,' res.data.data.access_token')
              this.$router.replace('/')
            })
          }
        })
      })
    })
  },

  methods: {

  }
}
</script>
